
//
//  HMStatusTool.m
//  黑马微博-wzy
//
//  Created by Mac on 2017/2/15.
//  Copyright © 2017年 Mac. All rights reserved.
//业务类
//加载最新的数据,加载更多的数据,加载从沙盒中获取的数据 等

#import "HMStatusTool.h"
#import "HMHttpTool.h"
#import "MJExtension.h"


@implementation HMStatusTool

+ (void)homeStatusWithParams:(HMHomeStatusesParam *)param success:(void (^)(HMHomeStatusesResult *result))success failure:(void (^)(NSError *error))failure{
    //(HMHomeStatusesParam *)param:传进来的参数为模型,但是数据请求的时候参数为字典,所以需要 模型->字典
    //模型转字典:把 param 转化为字典-> param.keyValues
//    [HMHttpTool get:@"https://api.weibo.com/2/statuses/home_timeline.json" params:param.keyValues success:^(id responseObj) {
//    //成功
//        if (success) {
//            //成功后返回的responseObj 为字典,需转化为模型
//            HMHomeStatusesResult *result = [HMHomeStatusesResult objectWithKeyValues:responseObj];
//            success(result);
//        }
//        
//    } failure:^(NSError *error) {
//    //失败
//        if (failure) {
//            failure(error);
//        }
//    
//     }];
    [self getWithUrl:@"https://api.weibo.com/2/statuses/home_timeline.json" params:param resultClass:[HMHomeStatusesResult class] success:success failure:failure];
}


+ (void)sendStatusWithParams:(HMSendStatusParam *)param success:(void (^)(HMSendStatusResult *result))success failure:(void (^)(NSError *error))failure{
    //(HMHomeStatusesParam *)param:传进来的参数为模型,但是数据请求的时候参数为字典,所以需要 模型->字典
    //模型转字典:把 param 转化为字典-> param.keyValues
//    [HMHttpTool get:@"https://api.weibo.com/2/statuses/update.json" params:param.keyValues success:^(id responseObj) {
//        //成功
//        if (success) {
//            //成功后返回的responseObj 为字典,需转化为模型
//            HMSendStatusResult *result = [HMSendStatusResult objectWithKeyValues:responseObj];
//            success(result);
//        }
//        
//    } failure:^(NSError *error) {
//        //失败
//        if (failure) {
//            failure(error);
//        }
//        
//    }];
    [self postWithUrl:@"https://api.weibo.com/2/statuses/update.json" params:param resultClass:[HMSendStatusResult class] success:success failure:failure];
    
}


@end
